package com.markerhub.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.markerhub.entity.TUnusualPerson;
import com.markerhub.mapper.TUnusualPersonMapper;
import com.markerhub.service.ITUnusualPersonService;
import com.markerhub.vo.response.PersonInfoVO;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 异常人员表 服务实现类
 * </p>
 *
 * @author zhz
 * @since 2021-09-18
 */
@Service
public class TUnusualPersonServiceImpl extends ServiceImpl<TUnusualPersonMapper, TUnusualPerson> implements ITUnusualPersonService {

    @Override
    public TUnusualPerson queryTUnusualPersonByImsi(String imsi) {
        LambdaQueryWrapper<TUnusualPerson> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(TUnusualPerson::getImsi, imsi);
        wrapper.last("limit 1");
        TUnusualPerson unusualPerson = baseMapper.selectOne(wrapper);
        return unusualPerson;
    }

    @Override
    public List<TUnusualPerson> selectByImsis(Set<String> imsis) {
        LambdaQueryWrapper<TUnusualPerson> wrapper = Wrappers.lambdaQuery();
        wrapper.select(TUnusualPerson::getImsi,TUnusualPerson::getName,TUnusualPerson::getCardId,TUnusualPerson::getMobile,
                TUnusualPerson::getHealthcodeState,TUnusualPerson::getAcidtestTime,
                TUnusualPerson::getAcidtestResult,TUnusualPerson::getVaccination,TUnusualPerson::getHodometer);
        wrapper.in(CollectionUtil.isNotEmpty(imsis),TUnusualPerson::getImsi,imsis);
        return list(wrapper);
    }

    @Override
    public List<TUnusualPerson> selectAll() {
        LambdaQueryWrapper<TUnusualPerson> wrapper = Wrappers.lambdaQuery();
        return list(wrapper);
    }
}
